<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
</head>

<body>
    <script>
        // 每一个函数都有prototype属性，默认指向空的Object空对象。（即：原型对象）
        function Cat(name) {
            this.name = name;
        }

        Cat.prototype.sell = function () {
            // console.log(this instanceof Object,'this');
            console.log(this.name + "唱歌123");
        };


        let c = new Cat("小猫");

        console.dir(Cat.__proto__, '000');

        // Cat.prototype 是Object 的实例对象
        console.log(Cat === Cat.prototype.constructor);

        console.log(c.__proto__ === Cat.prototype);

        console.log(c.__proto__.constructor === Cat);

        console.log(Cat.prototype instanceof Object);

        console.log(c.__proto__.__proto__ === Object.prototype);

        console.log(Cat.prototype.__proto__ === Object.prototype);

        // 实例对象的隐式原型(__proto__)指向 构造函数的原型对象(Cat.prototype)

        // 实例都有__proto__,构造函数都有原型 prototype


        //原型链设置
        function Preson() {

        }

        Preson.prototype.name = 'cat'
        Preson.prototype.say = function () {
            console.log('嫦娥');
        }
        let p1 = new Preson()
        console.log(p1.name);
        let p2 = new Preson()
        p2.say = function () {
            console.log('玉兔');
        }
        p2.name = 'pig'
        console.log(p2.name);
        console.log(p1.name);
        p1.say()
        p2.say()
        //  实例没有原型链去查找，但是修改不会去查找。只会在实例上修改



        



    </script>
</body>

</html>